import { HYEventStore } from 'hy-event-store'
import { getReqRecommend } from '../service/music'

// const rankingIds = [3779629,2884035,19723756]
export const rankingMap = {
  newRanking: 3779629,
  originRanking: 2884035,
  upRanking: 19723756
}
export const rankingStore = new HYEventStore({
  state: {
    newRanking: {},
    originRanking: {},
    upRanking: {}
  },
  actions: {
    fetchRankingData(state) {
      // for(var id of rankingIds) {
      //   getReqRecommend(id).then(res=> {
      //     if(id===3779629) {
      //       state.newRanking = res
      //     } else if(id===2884035) {
      //       state.originRanking = res
      //     } else {
      //       state.upRanking = res
      //     }
      //   })
      // }
      for (const key in rankingMap) {
        const id = rankingMap[key]
        getReqRecommend(id).then(res => {
          state[key] = res.playlist
        })
      }
    }
  }
})
